package com.cloudsigns.factorymanager2.engineering.activity;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.adapter.ProductInformationAdapter;
import com.cloudsigns.factorymanager2.project.bean.ProductBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tony on 2018/1/26.
 */

public class EditEngineeringInstallationOrderDetailActivity extends Activity implements View.OnClickListener {
    private ImageView img_back;
    private TextView tv_title;
    private ListView lv;
    private RelativeLayout rl_project;
    private LinearLayout ll_engineering_info_content;
    private ProductInformationAdapter adapter;
    private List<ProductBean> productBeanList = new ArrayList<>();
    private final String TAG = "EditEngineeringInstallationOrderDetailActivity";
    private ImageView img_project_select;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.layout_edit_engineering_installation_order_detail);

        init();
    }

    private void init() {
        img_back = findViewById(R.id.img_back);
        tv_title = findViewById(R.id.tv_title);
        lv = findViewById(R.id.lv);
        rl_project = findViewById(R.id.rl_project);
        ll_engineering_info_content = findViewById(R.id.ll_engineering_info_content);

        img_project_select = findViewById(R.id.img_project_select);


        tv_title.setText(getResources().getText(R.string.engineering_installation));
        img_project_select.setBackgroundResource(R.mipmap.arrow_down_icon);

        img_back.setOnClickListener(this);

        rl_project.setOnClickListener(this);


        adapter = new ProductInformationAdapter(this, TAG);
        adapter.setData(productBeanList);
        lv.setAdapter(adapter);

    }

    private void showEngineeringInfoDialog() {
        if (ll_engineering_info_content.getVisibility() == View.VISIBLE) {
            ll_engineering_info_content.setVisibility(View.GONE);
            img_project_select.setBackgroundResource(R.mipmap.arrow_down_icon);
        } else {
            ll_engineering_info_content.setVisibility(View.VISIBLE);
            img_project_select.setBackgroundResource(R.mipmap.arrow_top);
        }
    }


    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;

            case R.id.rl_project:
                showEngineeringInfoDialog();
                break;


        }
    }
}
